import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:largefriends/res/lf_color.dart';
import 'package:largefriends/res/lf_double_ext.dart';
import 'package:shimmer/shimmer.dart';

class LfMessageLoading extends StatelessWidget {
  const LfMessageLoading({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Shimmer.fromColors(
      baseColor: color8F8F8F,
      period: const Duration(seconds: 1),
      highlightColor: color210215.withAlpha(10),
      child: Padding(
        padding: EdgeInsets.symmetric(horizontal: 10.w),
        child: SingleChildScrollView(
          physics: const NeverScrollableScrollPhysics(),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              10.h.sbh,
              item(),
              10.h.sbh,
              item(),
              10.h.sbh,
              item(),
              10.h.sbh,
              item(),
              10.h.sbh,
              item(),
              10.h.sbh,
              item(),
              10.h.sbh,
              item(),
              10.h.sbh,
              item(),
              10.h.sbh,
              item(),
              10.h.sbh,
              item(),
              10.h.sbh,
              item(),
              10.h.sbh,
              item(),
              10.h.sbh,
            ],
          ),
        ),
      ),
    );
  }

  Widget item() {
    var width = Random().nextDouble() * ScreenUtil().screenWidth / 3;
    if (width < 60.w) {
      width = 60.w;
    }
    var width2 = Random().nextDouble() * ScreenUtil().screenWidth / 2;
    if (width2 < 120.w) {
      width2 = 120.w;
    }
    return Row(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        10.w.sbw,
        Container(
          decoration: const BoxDecoration(
            color: Colors.white,
            shape: BoxShape.circle,
          ),
          width: 50.r,
          height: 50.r,
        ),
        10.w.sbw,
        Expanded(
            child: Column(
          mainAxisSize: MainAxisSize.min,
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Container(
              decoration:
                  BoxDecoration(color: Colors.white, borderRadius: 10.r.radius),
              width: width,
              height: 16.r,
            ),
            5.h.sbh,
            Container(
              decoration:
                  BoxDecoration(color: Colors.white, borderRadius: 10.r.radius),
              width: width2,
              height: 10.r,
            ),
          ],
        )),
        10.w.sbw,
      ],
    );
  }
}
